package com.alibaba.citrus.cr.sales.plan.repository;

import com.alibaba.citrus.cr.sales.plan.dto.api.request.CreateContractRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.MonthContractAndRollingCountResponse;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.PageQueryContractRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.QueryContractByCustomerDimensionRequest;
import com.alibaba.citrus.cr.sales.plan.dto.api.request.QueryContractRequest;
import com.alibaba.citrus.cr.sales.plan.repository.request.SearchContractRepoReq;
import com.alibaba.citrus.cr.sales.plan.sdo.ContractSDO;
import com.alibaba.cz.base.tool.page.PageResult;
import com.epoch.app.bcorder.sales_plan.contract.dto.DeleteContractsByConditionsRequest;
import com.epoch.app.bcorder.sales_plan.contract.dto.QueryCountByYearRequest;

import java.util.List;

/**
 * @author wangyibing
 */
public interface ContractRepository {

    String createContract(CreateContractRequest createContractRequest);

    PageResult<List<ContractSDO>> pageQuery(PageQueryContractRequest pageQueryContractRequest, Boolean isFull);

    ContractSDO queryContractById(QueryContractRequest queryContractRequest);

    Integer editContract(ContractSDO editContractRequest);

    Integer updateSummaryContract(ContractSDO editContractRequest);

    String save(ContractSDO contractSDO);

    List<MonthContractAndRollingCountResponse> queryQuantityListByAddressAndScItem(
        QueryContractByCustomerDimensionRequest customerDimensionRequest);


    Integer batchCreateContract(List<ContractSDO> createContractRequestList);

    /**
     * 分组查询公司货品维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByCompanyScItem(String contractYear);

    /**
     * 分组查询销售组织货品维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesOrgScItem(String contractYear);

    /**
     * 分组查询销售渠道货品维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesChannelScItem(String contractYear);

    /**
     * 分组查询部门货品维度明细
     *
     * @return
     */

    List<ContractSDO> queryGroupByDepartmentScItem(String contractYear);

    /**
     * 分组查询业务员货品维度明细
     *
     * @return
     */

    List<ContractSDO> queryGroupByEmployeeScItem(String contractYear);

    /**
     * 分组查询公司维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByCompany(String contractYear);

    /**
     * 分组查询销售组织维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesOrganization(String contractYear);

    /**
     * 分组查询销售渠道维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesChannel(String contractYear);

    /**
     * 分组查询部门维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByDepartment(String contractYear);

    /**
     * 分组查询客户维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByCustomer(String contractYear);

    /**
     * 分组查询业务员维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByEmployee(String contractYear);

    /**
     * 分组查询公司类目维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByCompanyCategory(String contractYear);

    /**
     * 分组销售组织类目维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesOrgCategory(String contractYear);

    /**
     * 分组查询销售渠道类目维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupBySalesChannelCategory(String contractYear);

    /**
     * 分组查询部门类目维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByDepartmentCategory(String contractYear);

    /**
     * 分组查询业务员类目维度明细
     *
     * @return
     */
    List<ContractSDO> queryGroupByEmployeeCategory(String contractYear);

    List<String> queryContractYear();

    /**
     * 删除汇总合同量
     * @param contractYearList
     * @return
     */
    Boolean deleteStatContract(List<String> contractYearList,String orgBusinessUnitCode);

    /**
     * 根据ids删除合同量
     * @param ids
     * @return
     */
    Integer deleteContractByIds(List<Long> ids);


    /**
     * 根据条件删除合同量
     * @param
     * @return
     */
    Integer deleteContractByCondition(DeleteContractsByConditionsRequest request);



    PageResult<List<ContractSDO>> pageQueryDepartByRedCount(PageQueryContractRequest contractRequest);

    /**
     * es搜索合同量信息
     * @return
     */
    PageResult<List<ContractSDO>> searchContract(SearchContractRepoReq searchContractRepoReq);

    /**
     * 查询指定年份合同数量
     * @param request
     * @return
     */
    Integer queryCountByYear(QueryCountByYearRequest request);

    /**
     * db搜索合同量信息
     * @return
     */
    PageResult<List<ContractSDO>> pageQueryContract(SearchContractRepoReq searchContractRepoReq);

    /**
     * 简单分页查询
     * @return
     */
    PageResult<List<ContractSDO>> simplePageQueryContract(PageQueryContractRequest pageQueryContractRequest);
}
